package com.itstyle.seckill.topic.desinger.design_cj.composite;

/**
 * @Auther: liuwenxiang
 * @Date: 2019/9/18 20:01
 * @Description: 组合模式(接口定义多个方法,将对象组合起来,list管理对象)：定义一个具有多种能力的接口，然后将不同的构建组合起来
 */
public class Test {

    public static void main(String[] args) {

//树枝构件
        Component c0=new Composite();
        Component c1=new Composite();

//树叶构件
        Component leaf1=new Leaf("1");
        Component leaf2=new Leaf("2");
        Component leaf3=new Leaf("3");


        c0.add(leaf1);
        c0.add(c1);
        c1.add(leaf2);
        c1.add(leaf3);
        c0.operation();
    }
}
